#include "main.h"

#include "display.h"
#include "client.h"


int mode = 0;//home-0   picture-1
LINK_LIST *head;
LINK_NODE *show;
int stop = 1;


void handler(int signum){
    if(signum == SIGINT){
        stop = 0;
    }
}


int main()
{

    lcd_init(); //初始化显示屏
    touch_init();
    client_init("192.168.31.100", 8080);

    pthread_t pid ;
    pthread_create(&pid, NULL, get_direction_coord, NULL);
    pthread_t pid_socket ;
    pthread_create(&pid_socket, NULL, client_pid, NULL);

        head = list_create();
        get_bmp_path("/root/hcc/image", head);
        show_path(head);
        show = head->first;
        

    signal(SIGINT, handler);
    while(stop){
        display(mode);
        sleep(1);
    }
    
    //delete_head(head);
    lcd_uninit(); //解除初始化显示屏
    touch_uninit();
    delete_head(head);
    printf("=ffffffffffffffffffffine\n");
    return 0;


    /***************电子相册*********************************/
    // LINK_LIST *head = list_create();
    // get_bmp_path("/root/hcc/image", head);
    // show_path(head);

    // LINK_NODE * show = head->first;
    // signal(SIGINT, handler);
    // while (stop)
    // {
    //     int slide_dir = get_slide_direction();
    //     if(slide_dir == LEFT){
    //         show = show->next;
    //     }
    //     else if(slide_dir == RIGHT){
    //         show = show->prev;
    //     }
    //     show = show->prev;
    //     lcd_display_bmp(show->data, 0, 0);
    //     printf("%s\n",show->data);
    //     sleep(1);

    // }
    //delete_head(head);



    // /***************gy39*****************************/
    // while (1)
    // {
        
    //     get_gy39_data(COM2); //监测数据
    //     lcd_display_bmp("/root/hcc/backgrand.bmp",0,0);
    //     for(int i=0;i < 3;i ++){
    //     lcd_display_word(250, 100+i*100, 56, 64, title[i*2], 0xffffff);
    //     lcd_display_word(250+56, 100+i*100, 56, 64, title[i*2+1], 0xffffff);
    //     lcd_display_word(250+56+56, 100+i*100, 56, 64, title[6], 0xffffff);

    //     lcd_display_number(250+56+56+56, 100+i*100, 40, 64,gy39_data[i], 0xffffff);
    //     }
    // }

    
     
}